﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data;
using MySql.Data.MySqlClient;

namespace LibSystem
{
    public partial class PassChangeForm : Form
    {
        private String password;
        public PassChangeForm()
        {
            
            InitializeComponent();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void PassChangeForm_Load(object sender, EventArgs e)
        {
            String mystr = "select * from account where user = '" + TempData.user + "'";
            MySqlCommand mycmd = new MySqlCommand(mystr, TempData.myconn);
            MySqlDataReader myreader = mycmd.ExecuteReader();
            myreader.Read();
            password = myreader[1].ToString();
            myreader.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if ((textBox1.Text == password) && (textBox2.Text == textBox3.Text))
            {
                String mystr = "update account set password = '"+textBox2.Text+"' where user = '"+TempData.user+"';";
                MySqlCommand mycmd = new MySqlCommand(mystr, TempData.myconn);
                MySqlDataReader myreader = mycmd.ExecuteReader();
                myreader.Read();
                MessageBox.Show("修改成功", "Succeed", MessageBoxButtons.OK);
                myreader.Close();
                this.Close();
            }
            else
            {
                MessageBox.Show("cuowu", "cuowu", MessageBoxButtons.OK);
            }
            

        }

    }
}
